<?=$this->header()?>


    <?=$this->menu("downloads")?>


    <h1><?=$this->message("label.header", _Download::BUNDLE)?></h1>


    <? /* Breadcrums route & user info display */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.category.header", _Download::BUNDLE),
                "href"=>"download/category/list"
            ),
            $this->category($this->downloadListForm->getId())
        ), // Route display
        $this->downloadListForm,                             // ListForm (for download info, see float right)
        $this->downloads($this->downloadListForm)->getRows()) // The total amount of downloads
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->downloadListForm)?>"
          method="post"
          action="download/list"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "download/edit?revision->download->categoryId=".$this->downloadListForm->getId(), // Add New URL
            $this->downloadListForm, // ListForm
            array(                   // Filter fields
                DownloadPeer::DESCRIPTION=>$this->message("prompt.description", _Download::BUNDLE),
                BinaryFilePeer::FILE_NAME=>$this->message("label.filename", _Core::BUNDLE),
                DownloadPeer::PUBLICATION_DATE=>$this->message("prompt.publication", _Download::BUNDLE),
                DownloadRevisionPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                DownloadPeer::ACTIVE=>$this->message("choose.active", _Core::BUNDLE),
            ),
            false // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th>
                <?=$this->TH(
                    $this->downloadListForm,                                // ListForm
                    DownloadPeer::DESCRIPTION,                              // Sort Field
                    $this->message("prompt.description", _Download::BUNDLE) // Header Name
                )?>
            </th>
            <th>
                <?=$this->TH(
                    $this->downloadListForm,                        // ListForm
                    BinaryFilePeer::FILE_NAME,                      // Sort Field
                    $this->message("label.filename", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->downloadListForm,                         // ListForm
                    DownloadRevisionPeer::INSERT_DATE,               // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->downloadListForm,                      // ListForm
                    DownloadPeer::ACTIVE,                         // Sort Field
                    $this->message("label.active", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow" title="<?=$this->message("title.order", _Core::BUNDLE)?>">
                <?=$this->TH(
                    $this->downloadListForm,                      // ListForm
                    DownloadPeer::POSITION,                       // Sort Field
                    $this->message("label.order", _Core::BUNDLE), // Header Name
                    "ASC"
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->downloads($this->downloadListForm)->getItems() as $revision) { ?>

            <? /* Display the default language download */ ?>
            <tr class="ctrl">
                <td class="checkbox">

                    <input type="checkbox"
                           name="items[]"
                           value="<?=$revision->getDownloadId()?>"
                           <?=in_array($revision->getDownloadId(), $this->downloadListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td><?=$this->truncateNicely($revision->getDownload()->getDescription(), 16, 26, "...")?></td>
                <td>
                    <a title="<?=$this->message("title.download")?>" href="download?id=<?=$revision->getBinaryFileId()?>">
                        <?=$this->truncateNicely($revision->getBinaryFile()->getFileName(), 16, 26, "...")?>
                    </a>
                </td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$revision->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$revision->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.active", _Core::BUNDLE)?>">
                    <?=$this->message("label." . ($revision->getDownload()->getActive() ? "yes" : "no"), _Core::BUNDLE)?>
                </td>
                <td title="<?=$this->message("title.move", _Core::BUNDLE)?>">

                    <? if($revision->getDownload()->getPosition() > 1): ?>
                        <input type="image" onclick="moveup(<?=$revision->getDownloadId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_up.png")?>" alt=""
                               alt="<?=$this->message("title.move.up", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.up", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                    <? if($revision->getDownload()->getPosition() < $revision->getDownload()->getMaxPosition()): ?>
                        <input type="image" onclick="movedown(<?=$revision->getDownloadId()?>, this.form)"
                               src="static.php?file=<?=$this->image("cms/core/view/gfx/arrow_down.png")?>"
                               alt="<?=$this->message("title.move.down", _Core::BUNDLE)?>"
                               title="<?=$this->message("title.move.down", _Core::BUNDLE)?>. <?=$this->message("title.move", _Core::BUNDLE)?>" />
                    <? endif; ?>

                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('download/edit?revision->downloadRevisionId=<?=$revision->getDownloadRevisionId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$revision->getDownloadId()?>, '<?=get_class($this->downloadListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->downloadListForm, // ListForm
            array(                   // The actions
                "activate"=>$this->message("choose.activate", _Core::BUNDLE),
                "deactivate"=>$this->message("choose.deactivate", _Core::BUNDLE),
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->downloadListForm,                                                // ListForm
            "download/edit?revision->download->categoryId=".$this->downloadListForm->getId(), // Add New URL
            $this->downloads($this->downloadListForm)->getRows()                    // The total amount of users
        )?>


    </form>

<?=$this->footer()?>